
Component({
    
    data: {
        
    },
    methods: {
        switchTab(event) {
            // data为接受到的参数
            const data = event.currentTarget.dataset;
            var index = data.index;
            var url = '/'+data.path;
            //const page = getCurrentPages().pop();
            console.log(data)
            // 取出参数中的path作为路由跳转的目标地址
            wx.reLaunch({
               url: url
            });
        },
        init(id='') {
            console.log('---id='+id+'----')
            const page = getCurrentPages().pop();
            var  tab = wx.getStorageSync('tabBar');
            var tabBar = tab[0];
            var url = page.route;
            var list = tabBar.list;
            var tabIndex=0;
            list.forEach(function(item,index){
              
                if(url == item.pagePath){
                    console.log(item.pagePath);
                    tabIndex=index;
                    console.log(tabIndex)

                }
            })
            //console.log(url);
            //var 
            this.setData({
                tabBar:tabBar,
                tabIndex:tabIndex
            })
            
            //wx.setStorageSync('tabIndex',index)
            console.log(page)
    
          }
    }
})